<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/jquery.masonry.min.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->javascriptCaptureStart()?>
$(window).load(function(){
    $(function(){
        $('#list').masonry({
            // options
            itemSelector : '.item'
        });
    });
});
<?php $this->JQuery()->javascriptCaptureEnd()?>

<?php
$get = $_GET;
if (!empty($this->category) && $req['module'] !== 'search') {
    $url = '';
    foreach($get as $k => $v) {
        if (is_array($v)) {
            foreach($v as $k2 => $v2) {
                $url .= $k.'['.$k2.']'.'='.$v2.'&';
            }
        } else {
            $url .= $k.'='.$v.'&';
        }
    }
    $url = $this->category->url().'?'. $url;
} else {
    $url = $this->obj->url(false, $_GET);
}
$separator = (strpos($url, '?') !== false) ? '&' : '?'; 
?>
<section class="result gallery hor">
	<section class="business_personal">  
		<a href="#" class="selected"><em><?php echo $this->t('所有信息')?></em> (<?php echo $this->listing_number?>)</a>
	</section>
			<section class="search">
		        <form action="<?php if (!empty($this->company)) {echo $this->company->url();} if (!empty($this->user)) {echo $this->user->url();}?>" method="GET">
		          	<input type="text" value="" name="keyword">
		          	<button><?php echo $this->t('Search')?></button>
		        </form>
	      	</section>
            <ul id="list">
                <?php foreach($this->list as $listing):?>
                    <?php $item = Model_Listing::find($listing->id);?>
                    <?php if(empty($item)){ continue;}?>
                    <li class="item">
                        <?php
                            $this->partial()->setObjectKey('model');
                            echo $this->partial(
                                'index/listing-element.phtml', 
                                'search',
                                array(
                                    'item'                  => $item,
                                    'photo_width'           => 247,
                                    'photo_height'          => 247,
                                    'photo_params'          => array(false),
                                    'display_photo_if_not_exists' => false,
                            ));
                        ?>
                    </li>
                <?php endforeach;?>
            </ul>
            
            <?php $url1 = preg_replace('#page=[^&]*#', '', $url);?>
            <?php $pagination = $this->pagination($this->listing_number, $this->page, $this->per_page, 4, $url1);?>
            <section class="nav option top">
                <dl class="sort">
                    <dt><?php echo $this->t('排列')?></dt>
                    <dd>
                        <?php foreach($this->sort_by as $k => $value):?>
                            <?php $url1 = preg_replace('#sort=[^&]*#', '', $url);?>
                            <a href="<?php echo $url1.$separator.'sort='.$k?>" class="<?php echo $this->sort == $k ? 'selected': ''?>"><?php echo $value;?></a>
                        <?php endforeach;?>
                    </dd>
                </dl>
                <dl class="view">
                    <dt><?php echo $this->t('显示')?></dt>
                    <dd>
                        <a class="selected" href="#"><?php echo $this->t('相集')?></a>
                        <a href="<?php echo preg_replace('#&view=[^&]*#', '', $url) . $separator . 'view=list'?>"><?php echo $this->t('列表')?></a>
                    </dd>
                </dl>
                <?php echo $pagination;?>
            </section>
            <section class="nav option bottom">
                <dl class="sort">
                    <dt><?php echo $this->t('排列')?></dt>
                     <dd>
                        <?php foreach($this->sort_by as $k => $value):?>
                            <?php $url1 = preg_replace('#&sort=[^&]*#', '', $url);?>
                            <a href="<?php echo $url1.$separator.'sort='.$k?>" class="<?php echo $this->sort == $k ? 'selected': ''?>"><?php echo $value;?></a>
                        <?php endforeach;?>
                    </dd>
                </dl>
                <dl class="view">
                    <dt><?php echo $this->t('显示')?></dt>
                    <dd>
                        <a class="selected" href="#"><?php echo $this->t('相集')?></a>
                        <a href="<?php echo preg_replace('#&view=[^&]*#', '', $url) . $separator . 'view=list'?>"><?php echo $this->t('列表')?></a>
                    </dd>
                </dl>
                <?php echo $pagination;?>
</section>
